<?php
/**
 * 景点
 */
namespace App\Http\Controllers\Admin\Member;


use App\Http\Controllers\Admin\Business\Service\Combo;
use App\Http\Controllers\Admin\Business\Service\ComboActivities;
use App\Http\Controllers\Admin\Business\Service\ComboOrder;
use App\Http\Controllers\Admin\Business\Repository\ComboOrder as ComboOrderRepository;
use App\Setting;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

class RechargeController extends Controller
{
    private $manager;
    private $repository;
    private $request;
    private $viewPrefix = 'admin.member.recharge.';
    private $routePrefix = 'admin.member.recharge';
    public function __construct (Request $request)
    {
        $this->manager = new ComboOrder();
        $this->repository = new ComboOrderRepository();
        $this->request = $request;
    }

    /**
     * 文章列表
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(){
        if(isset($this->request->act)){
            $act = $this->request->act;
            return $this->{$act}();
        }else{

            return view($this->viewPrefix.'index',[
                'manager'   =>  $this->manager,
                'routePrefix'   =>  $this->routePrefix,
            ]);
        }

    }

    /**
     * ajax列表
     * @return array
     */
    public function indexAjax(){

        return $this->page_json_render($this->manager->getPageList($this->request));
    }

    public function read($id){
        $model  = $this->manager->getComboOrder($id);
        $sysRate = [
            'rate'  =>  Setting::getConfig('rate','分销设置'),
            'top_rate'  =>  Setting::getConfig('topRate','分销设置')
        ];
        $reduce_type = ComboActivities::REDUCE;
        return view($this->viewPrefix.'read',[
            'manager'   =>  $this->manager,
            'routePrefix'   =>  $this->routePrefix,
            'model' =>  $model,
            'rate_type_user' =>  Combo::RATE_TYPE_USER,
            'sysRate'   =>  $sysRate,
            'reduce_type'   =>  $reduce_type
        ]);
    }
    /**
     * @return array
     */
    private function hide(){
        $this->manager->hide($this->request->id);
        return  ['info'  =>  'success'];
    }
    private function show(){
        $this->manager->show($this->request->id);
        return  ['info'  =>  'success'];
    }

}
